<?php
/* $Id: save.reports.php,v 1.3 2003/10/08 07:24:55 tuxmonkey Exp $ */
if (strpos($_SERVER['PHP_SELF'],basename(__FILE__)) !== false) {
  print "Direct module access forbidden.".basename(__FILE__);exit;}
  


if (empty($_POST['reportname'])) {
  push_error("Please enter a name for this report.");
}

$descr = $_POST['description'];

if (empty($descr)) {
   $descr = "<none>";
   }

if (!errors()) {
  $insert['name'] = $_POST['reportname'];
  $insert['descr'] = $_POST['description'];
  $insert['options'] = $_POST['saved'];
  $insert['userid'] = $_SESSION['userid'];
  $id = $dbi->insert("reports",$insert,null,"reports_rid_seq");
  if (!empty($id)) {
    push_info("Report saved successfully.");
    redirect("?module=reports&action=generate&rid=$id");
  } else {
    push_error("Report could not be saved!");
    redirect("?module=reports");
  }
}

$smarty->assign('saved',$_POST['saved']);
$smarty->display("reports/save.tpl");
?>